<template>
	<view class="content">

		<!-- 自定义顶部搜索框 用于搜索跳转 skipUrl:跳转url为绝对路径 /pages开头 -->
		<!-- <cc-headSearch skipUrl="/pages/index/search"></cc-headSearch> -->
		<view class="headerSearch">
			<view class="searchBox" @click="search">
				<image src="@/static/search_icon.png" mode=""></image>
				<text>{{keyWord==''?'搜索全部':keyWord}}</text>
			</view>
		</view>
		
		<cc-defineTable2 :tableData="datas"></cc-defineTable2>

	</view>
</template>

<script>
	import hantangbaifenbi_ from './js/hantangbaifenbi'
	
	export default {
		components: {

		},

		data() {
			return {
				keyWord: '',
				dataSource: [],
				datas: [],
				images: ['/static/sugar/hantangbaifenbi.png']
			}
		},
		computed: {
		},
		mounted() {

		},
		onLoad(option) {
			this.initData();
			
		},
		methods: {
			itemFilter(param){
				this.keyWord = param.keyWord
				if(!this.keyWord){
					console.log(this.dataSource)
					this.initData();
				} else {
					var tableArr = JSON.parse(JSON.stringify(this.dataSource)); 
					var tableArr_ = [];
					var list_ = [];
					for(var index in tableArr){
						var data = tableArr[index]
						var list = data.list
						
						list_ = [];
						list.filter((item) => {
							// 返回名称包含搜索查询的产品
							if(item.name.includes(this.keyWord)){
								list_.push(item)
							}
						});
						data.list = list_;
						tableArr_.push(data);
					}
					
					this.datas = [];
					this.datas = tableArr_;
				}
				
			},
			initData(){
				let hantangbaifenbi = hantangbaifenbi_[0]
				var dataSource_ = [];
				dataSource_.push(hantangbaifenbi)
				this.datas = dataSource_;
				this.dataSource = dataSource_
			},
			search(){
				uni.showToast({
					title: '更多功能，程序猿小哥哥开发中..',
					icon: 'none'
				})
				// uni.navigateTo({
				// 	url: '/pages/index/search'
				// })
			},
			previewImage() {
				uni.previewImage({
					urls: this.images,
					// current: index,
					// indicator: this.currentIndicator,
					// loop: this.isLoop
				})
			},
			onShareAppMessage(){//点亮发送给朋友
			    return {
			      title: '帮助需要的朋友们',//标题
			      path: '/pages/sugar/index'//路径
			    }
			},
			onShareTimeline() {}//点亮分享朋友圈,暂只支持Android平台

		},
		
	}
</script>

<style>
	page {

		background-color: #f7f7f7;
	}
	.responsive-img {
	  max-width: 100%;
	  margin: 0 auto;
	  display: block;
	}
	.content {
		display: flex;
		flex-direction: column;

	}
	
	.headerSearch {
		height: 110rpx;
		background: #fff;
		width: 100%;
		overflow: hidden;
	}
	
	.searchBox {
		width: 92%;
		height: 70rpx;
		background: #F4F4F4;
		font-size: 28rpx;
		color: #999;
		border-radius: 10rpx;
		margin: 20rpx auto;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	
	.searchBox navigator {}
	
	.searchBox image {
		width: 18px;
		height: 18px;
		margin-right: 10rpx;
	}
	.info-view{
		display: flex; align-items: center; justify-content: center; color: blue;
	}
	
</style>